{% extends 'backend/backend_base.html' %}

{% block article %}
    <h3>添加文章</h3>
    <form action="" method="post">
        {% csrf_token %}
        <p>标题</p>
        <div>
            <input type="text" class="form-control" name="title">
        </div>
        <p>内容</p>
        <div>
            <textarea name="content" id="id_content" cols="30" rows="10"></textarea>
        </div>
        <p>分类</p>
        <div>
            {% for category in category_list %}
                <span>
                    <input type="radio" name="category" value="{{ category.pk }}">{{ category.name }}
                </span>
            {% endfor %}
        </div>
        <p>标签</p>
        <div>
            {% for tag in tag_list %}
                <input type="checkbox" name="tag" value="{{ tag.pk }}">{{ tag.name }}
            {% endfor %}
        </div>
        <input type="submit" class="btn btn-danger">
    </form>
{% endblock %}

{% block js %}
    {% load static %}
    <script charset="utf-8" src="{% static 'kindeditor-4.1.11-zh-CN/kindeditor/kindeditor-all-min.js' %}"></script>
    <script>
            KindEditor.ready(function(K) {
                    window.editor = K.create('#id_content', {
                        width : '100%',
                        height: '700px',
                        resizeType: 1,
                        uploadJson: '/upload_image/',  //上传图片的后端提交路径
                        extraFileUploadParams : {
                            'csrfmiddlewaretoken': '{{ csrf_token }}'
                }
                    });
            });
    </script>
{% endblock %}